export function getLocal(success) {
	uni.getLocation({
		type: 'gcj02',
		geocode:true,
		success: function(re) {
			console.log(re)
			uni.chooseLocation({
				latitude: re.latitude,
				longitude: re.longitude,
				success: function(resp) {
					
					/**
					 * 逆地理编码
					 * 参考 https://lbs.amap.com/api/webservice/guide/api/georegeo
					 */
					uni.request({
						url:"https://restapi.amap.com/v3/geocode/regeo",
						method:'get',
						data: {
						  location: resp.longitude + "," + resp.latitude,//位置坐标:格式：location=lng<经度>,lat<纬度>
						  key: '25e5ef05cfc6f4e7dd0309bc1a570a63',//开发密钥（web服务Key）
						  radius: 0,
						  extensions: 'all',//base，返回基本地址信息；all 时会返回基本地址信息、附近 POI 内容、道路信息以及道路交叉口信息
						  batch: false,
						  roadlevel: 1
						},
						success: function (res) {
							console.log(res,'====');
						  const data = res.data.regeocode;
						  const province = data.addressComponent.province;//省
						  const city = data.addressComponent.city;//市
						  const district = data.addressComponent.district;//区
						  const township = data.addressComponent.township;//街道
						  const address = township + data?.pois[0]?.name + data?.pois[0]?.address;
						  const reasult = {
							  province,
							  city,
							  district,
							  address,
						  }
						  success(reasult);
						},
						error: function (err) {
							uni.$u.toast("服务端错误，请重试");
						}
					
					})
				},
				fail(err) {
					uni.$u.toast("已取消");
					console.log(err,'err');
				},
			});
		}
	});
}
